package com.hnx.admin.aurora.system.controller;

import com.hnx.admin.aurora.annotation.Log;
import com.hnx.admin.aurora.enums.BusinessType;
import com.hnx.admin.aurora.system.domain.param.notice.form.NoticeForm;
import com.hnx.admin.aurora.system.domain.param.notice.query.NoticeQuery;
import com.hnx.admin.aurora.system.service.SysNoticeService;
import com.hnx.admin.aurora.web.json.ResultJson;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/*
创建人： 倔强的头发
创建时间：2025/7/5
功能描述:

*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/system/notice")
public class SysNoticeController {
    private final SysNoticeService noticeService;
    /**
     * 获取通知公告列表
     */
    @PreAuthorize("@auth.hasPermi('system:notice:list')")
    @GetMapping("/list")
    public ResultJson list(NoticeQuery notice)
    {
        return noticeService.selectNoticeList(notice);
    }
    /**
     * 根据通知公告编号获取详细信息
     */
    @PreAuthorize("@auth.hasPermi('system:notice:query')")
    @GetMapping(value = "/{noticeId}")
    public ResultJson getInfo(@PathVariable String noticeId)
    {
        return noticeService.selectNoticeById(noticeId);
    }
    /**
     * 新增通知公告
     */
    @PreAuthorize("@auth.hasPermi('system:notice:add')")
    @Log(title = "通知公告", businessType = BusinessType.INSERT)
    @PostMapping
    public ResultJson add(@Validated @RequestBody NoticeForm notice)
    {
        return noticeService.insertNotice(notice);
    }
    /**
     * 修改通知公告
     */
    @PreAuthorize("@auth.hasPermi('system:notice:edit')")
    @Log(title = "通知公告", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResultJson edit(@Validated @RequestBody NoticeForm notice)
    {
        return noticeService.updateNotice(notice);
    }
    /**
     * 删除通知公告
     */
    @PreAuthorize("@auth.hasPermi('system:notice:remove')")
    @Log(title = "通知公告", businessType = BusinessType.DELETE)
    @DeleteMapping("/{noticeIds}")
    public ResultJson remove(@PathVariable String[] noticeIds)
    {
        return noticeService.deleteNoticeByIds(noticeIds);
    }
}
